﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_MATERIAL_BOM
// * CreateDate    : 2011-11-21 11:55:18
// * Creater       : CodeSmith
// * LastChangeDate: 2011-11-21 11:55:18
// * LastChanger   : 2011-11-21 11:55:18
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESOL.Common.Entity;
using Suzsoft.Smart.Data;
using System.Data;
using ESOL.Common;

namespace ESOL.Business.Prod
{
    /// <summary>
    /// ProdMaterialBom
    /// </summary>
    public partial class ProdMaterialBomBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdMaterialBomEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdMaterialBomEntity GetProdMaterialBom(ProdMaterialBomEntity objProdMaterialBomEntity)
        {
            return DataAccess.SelectSingle<ProdMaterialBomEntity>(objProdMaterialBomEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdMaterialBomEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdMaterialBom(ProdMaterialBomEntity objProdMaterialBomEntity)
        {
            return DataAccess.Insert(objProdMaterialBomEntity);
        }

        public static bool InsertProdMaterialBom(List<ProdMaterialBomEntity> objProdMaterialBomEntityList)
        {
            return DataAccess.Insert(objProdMaterialBomEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdMaterialBomEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdMaterialBom(ProdMaterialBomEntity objProdMaterialBomEntity)
        {
            return DataAccess.Update(objProdMaterialBomEntity);
        }

        public static bool UpdateProdMaterialBom(List<ProdMaterialBomEntity> objProdMaterialBomEntityList)
        {
            return DataAccess.Update<ProdMaterialBomEntity>(objProdMaterialBomEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdMaterialBomEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdMaterialBom(ProdMaterialBomEntity objProdMaterialBomEntity)
        {
            return DataAccess.Delete(objProdMaterialBomEntity);
        }

        public static bool DeleteProdMaterialBom(List<ProdMaterialBomEntity> objProdMaterialBomEntityList)
        {
            return DataAccess.Delete<ProdMaterialBomEntity>(objProdMaterialBomEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdMaterialBomAll()
        {
            return DataAccess.SelectAllDataSet<ProdMaterialBomEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdMaterialBomEntity> GetProdMaterialBomAllList()
        {
            return DataAccess.SelectAll<ProdMaterialBomEntity>();
        }
        #endregion

        #region Functions
        public static ProdMaterialBomEntity GetProdMaterialBomByID(string ID)
        {
            if (string.IsNullOrEmpty(ID))
                return null;
            ProdMaterialBomEntity m = new ProdMaterialBomEntity();
            m.BomId = ID;
            return DataAccess.SelectSingle<ProdMaterialBomEntity>(m);
        }
        public static ProdMaterialBomEntity GetProdMaterialBomByProductID(string ProductID)
        {
            if (string.IsNullOrEmpty(ProductID))
                return null;
            string Sql = @"SELECT * FROM PROD_MATERIAL_BOM WHERE PRODUCT_ID='"+ProductID+"' ";
            List<ProdMaterialBomEntity> list = DataAccess.Select<ProdMaterialBomEntity>(Sql);
            if (list != null && list.Count > 0)
                return list[0];
            else return null;
        }
        #endregion
    }


}

